package com.inifitness.common.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * RedisKey的常量字符串
 *
 * @author sunjinfeng
 * @version 1.0.0
 * @since 2024/04/18 11:00:00
 */
@Getter
@AllArgsConstructor
public enum RedisKey {

  ;

  private final String key;

  /**
   * RedisKey的前缀，注意这里不要有：方法中会拼接上：
   */
  @Getter
  @AllArgsConstructor
  public enum Prefix {
    DICT_PREFIX("dict");

    private final String key;
  }

  @Getter
  @AllArgsConstructor
  public enum Suffix {
    DICT_SUFFIX("dict");

    private final String key;
  }

  public static String getKey(Prefix prefix, String key) {
    return prefix.getKey() + ":" + key;
  }

  public static String getKey(Prefix prefix, String key, Suffix suffix) {
    return prefix.getKey() + ":" + key + ":" + suffix.getKey();
  }

  public static String getKey(String key, Suffix suffix) {
    return key + ":" + suffix.getKey();
  }
}
